package org.jvending.provisioning.config.adapters.impl;

public class AdapterTypeHandler extends org.apache.ws.jaxme.impl.JMSAXElementParser {
    /**
     * The current state. The following values are valid states:
     * 0 = Before parsing the element
     * 1 = While or after parsing the child element {http://java.sun.com/xml/ns/j2ee-cp}adapter-name
     * 2 = While or after parsing the child element {http://java.sun.com/xml/ns/j2ee-cp}adapter-class
     * 3 = While or after parsing the child element {http://java.sun.com/xml/ns/j2ee-cp}base-uri
     * 4 = While or after parsing the child element {http://java.sun.com/xml/ns/j2ee-cp}descriptor-file
     * 5 = While or after parsing the child element {http://java.sun.com/xml/ns/j2ee-cp}fulfillment-duration
     * 6 = While or after parsing the child element {http://java.sun.com/xml/ns/j2ee-cp}init-param
     */
    private int __state;


    public boolean startElement(java.lang.String pNamespaceURI, java.lang.String pLocalName, java.lang.String pQName, org.xml.sax.Attributes pAttr) throws org.xml.sax.SAXException {
        org.apache.ws.jaxme.impl.JMUnmarshallerHandlerImpl _1 = getHandler();
        switch (__state) {
            case 0:
                if ("http://java.sun.com/xml/ns/j2ee-cp".equals(pNamespaceURI) && "adapter-name".equals(pLocalName)) {
                    __state = 1;
                    _1.addSimpleAtomicState();
                    return true;
                }
                break;
            case 1:
                if ("http://java.sun.com/xml/ns/j2ee-cp".equals(pNamespaceURI) && "adapter-class".equals(pLocalName)) {
                    __state = 2;
                    _1.addSimpleAtomicState();
                    return true;
                }
                break;
            case 2:
                if ("http://java.sun.com/xml/ns/j2ee-cp".equals(pNamespaceURI) && "base-uri".equals(pLocalName)) {
                    __state = 3;
                    _1.addSimpleAtomicState();
                    return true;
                }
                break;
            case 3:
                if ("http://java.sun.com/xml/ns/j2ee-cp".equals(pNamespaceURI) && "descriptor-file".equals(pLocalName))
                {
                    __state = 4;
                    org.apache.ws.jaxme.JMManager _2 = getHandler().getJMUnmarshaller().getJAXBContextImpl().getManagerS(org.jvending.provisioning.config.adapters.DescriptorFile.class);
                    java.lang.Object _3 = _2.getElementS();
                    org.apache.ws.jaxme.impl.JMSAXElementParser _4 = _2.getHandler();
                    _4.init(_1, _3, "http://java.sun.com/xml/ns/j2ee-cp", "descriptor-file", _1.getLevel());
                    _4.setAttributes(pAttr);
                    _1.addElementParser(_4);
                    return true;
                } else
                if ("http://java.sun.com/xml/ns/j2ee-cp".equals(pNamespaceURI) && "fulfillment-duration".equals(pLocalName))
                {
                    __state = 5;
                    _1.addSimpleAtomicState();
                    return true;
                }
                break;
            case 4:
                if ("http://java.sun.com/xml/ns/j2ee-cp".equals(pNamespaceURI) && "fulfillment-duration".equals(pLocalName))
                {
                    __state = 5;
                    _1.addSimpleAtomicState();
                    return true;
                }
                break;
            case 5:
                if ("http://java.sun.com/xml/ns/j2ee-cp".equals(pNamespaceURI) && "init-param".equals(pLocalName)) {
                    __state = 6;
                    org.apache.ws.jaxme.JMManager _5 = getHandler().getJMUnmarshaller().getJAXBContextImpl().getManagerS(org.jvending.provisioning.config.adapters.InitParam.class);
                    java.lang.Object _6 = _5.getElementS();
                    org.apache.ws.jaxme.impl.JMSAXElementParser _7 = _5.getHandler();
                    _7.init(_1, _6, "http://java.sun.com/xml/ns/j2ee-cp", "init-param", _1.getLevel());
                    _7.setAttributes(pAttr);
                    _1.addElementParser(_7);
                    return true;
                }
                break;
            case 6:
                if ("http://java.sun.com/xml/ns/j2ee-cp".equals(pNamespaceURI) && "init-param".equals(pLocalName)) {
                    __state = 6;
                    org.apache.ws.jaxme.JMManager _8 = getHandler().getJMUnmarshaller().getJAXBContextImpl().getManagerS(org.jvending.provisioning.config.adapters.InitParam.class);
                    java.lang.Object _9 = _8.getElementS();
                    org.apache.ws.jaxme.impl.JMSAXElementParser _10 = _8.getHandler();
                    _10.init(_1, _9, "http://java.sun.com/xml/ns/j2ee-cp", "init-param", _1.getLevel());
                    _10.setAttributes(pAttr);
                    _1.addElementParser(_10);
                    return true;
                }
                break;
            default:
                throw new java.lang.IllegalStateException("Invalid state: " + __state);
        }
        return false;
    }

    public void endElement(java.lang.String pNamespaceURI, java.lang.String pLocalName, java.lang.String pQName, java.lang.Object pResult) throws org.xml.sax.SAXException {
        org.jvending.provisioning.config.adapters.AdapterType _1 = (org.jvending.provisioning.config.adapters.AdapterType) result;
        switch (__state) {
            case 1:
                if ("http://java.sun.com/xml/ns/j2ee-cp".equals(pNamespaceURI) && "adapter-name".equals(pLocalName)) {
                    _1.setAdapterName((java.lang.String) pResult);
                    return;
                }
                break;
            case 2:
                if ("http://java.sun.com/xml/ns/j2ee-cp".equals(pNamespaceURI) && "adapter-class".equals(pLocalName)) {
                    _1.setAdapterClass((java.lang.String) pResult);
                    return;
                }
                break;
            case 3:
                if ("http://java.sun.com/xml/ns/j2ee-cp".equals(pNamespaceURI) && "base-uri".equals(pLocalName)) {
                    _1.setBaseUri((java.lang.String) pResult);
                    return;
                }
                break;
            case 4:
                if ("http://java.sun.com/xml/ns/j2ee-cp".equals(pNamespaceURI) && "descriptor-file".equals(pLocalName))
                {
                    _1.setDescriptorFile(((org.jvending.provisioning.config.adapters.DescriptorFileType) pResult));
                    return;
                }
                break;
            case 5:
                if ("http://java.sun.com/xml/ns/j2ee-cp".equals(pNamespaceURI) && "fulfillment-duration".equals(pLocalName))
                {
                    _1.setFulfillmentDuration((java.lang.String) pResult);
                    return;
                }
                break;
            case 6:
                if ("http://java.sun.com/xml/ns/j2ee-cp".equals(pNamespaceURI) && "init-param".equals(pLocalName)) {
                    _1.getInitParam().add(pResult);
                    return;
                }
                break;
            default:
                throw new java.lang.IllegalStateException("Illegal state: " + __state);
        }
    }

    public boolean isFinished() {
        switch (__state) {
            case 6:
            case 5:
                return true;
            default:
                return false;
        }
    }

}
